home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / gs24src.zip / GSMATRIX.H < prev    next >
C/C++ Source or Header  |  1992-03-05  |  3KB  |  70 lines

  1. /* Copyright (C) 1989, 1990, 1991 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.  */
  19.  
  20. /* gsmatrix.h */
  21. /* Definition of matrices and matrix routines for Ghostscript library */
  22.  
  23. #ifndef gsmatrix_INCLUDED
  24. #  define gsmatrix_INCLUDED
  25.  
  26. /* See p. 65 of the PostScript manual for the semantics of */
  27. /* transformation matrices. */
  28.  
  29. /* Structure for a transformation matrix. */
  30. /* This is a machine-dependent hack to avoid importing */
  31. /* the full definition of a Ghostscript type-tagged reference. */
  32. #define _matrix_body\
  33.     long _xx /*skip*/; float xx;\
  34.     long _xy /*skip*/; float xy;\
  35.     long _yx /*skip*/; float yx;\
  36.     long _yy /*skip*/; float yy;\
  37.     long _tx /*skip*/; float tx;\
  38.     long _ty /*skip*/; float ty
  39. typedef struct gs_matrix_s {
  40.     _matrix_body;
  41. } gs_matrix;
  42. /* Macro for initializing constant matrices */
  43. #define constant_matrix_body(xx, xy, yx, yy, tx, ty)\
  44.     0L,(float)(xx), 0L,(float)(xy), 0L,(float)(yx),\
  45.     0L,(float)(yy), 0L,(float)(tx), 0L,(float)(ty)
  46.  
  47. /* The identity matrix (for structure initialization) */
  48. #define identity_matrix_body\
  49.     constant_matrix_body(1, 0, 0, 1, 0, 0)
  50.  
  51. /* Matrix creation */
  52. void    gs_make_identity(P1(gs_matrix *));
  53. int    gs_make_translation(P3(floatp, floatp, gs_matrix *)),
  54.     gs_make_scaling(P3(floatp, floatp, gs_matrix *)),
  55.     gs_make_rotation(P2(floatp, gs_matrix *));
  56.  
  57. /* Matrix arithmetic */
  58. int    gs_matrix_multiply(P3(const gs_matrix *, const gs_matrix *, gs_matrix *)),
  59.     gs_matrix_invert(P2(const gs_matrix *, gs_matrix *)),
  60.     gs_matrix_rotate(P3(const gs_matrix *, floatp, gs_matrix *));
  61.  
  62. /* Coordinate transformation */
  63. int    gs_point_transform(P4(floatp, floatp, const gs_matrix *, gs_point *)),
  64.     gs_point_transform_inverse(P4(floatp, floatp, const gs_matrix *, gs_point *)),
  65.     gs_distance_transform(P4(floatp, floatp, const gs_matrix *, gs_point *)),
  66.     gs_distance_transform_inverse(P4(floatp, floatp, const gs_matrix *, gs_point *)),
  67.     gs_bbox_transform_inverse(P3(gs_rect *, gs_matrix *, gs_rect *));
  68.  
  69. #endif                    /* gsmatrix_INCLUDED */
  70.